package com.acme.domain.bank;

import java.io.Serializable;
import com.acme.domain.client.Client;
import com.acme.exceptions.ClientExistsException;

public class Bank implements Serializable {
	private static final long serialVersionUID = 1L;

	private final Client[] clients;
	private int maxClients = 0;

	public Bank(final int bankSize) {
		clients = new Client[bankSize];
	}

	public Client addClient(final Client client) throws ClientExistsException {
		for (int i = 0; i < maxClients; i++) {
			if (clients[i].getName() == client.getName()) {
				throw new ClientExistsException("Client " + client.getName() +
						" already exists");
			}
		}
		clients[maxClients++] = client;
		return client;
	}

	public Client[] getClients() {
		return clients;
	}

	public int getBankSize() {
		return maxClients;
	}
}
